1. Field of the Invention
The present invention relates to a CPU capable of modifying built-in program codes thereof and a method for modifying built-in program codes of the CPU, more particularly, to a CPU, which can modify the built-in program codes thereof by combining a ROM and a RAM as a program memory thereof.
2. Description of Related Art
Some constant program codes are necessary for a CPU to operate normally. Considering the cost, a read-only memory (ROM) is generally used as a program memory for storing programs and data codes.
FIG. 1 shows a general construction of the CPU, which comprises a program counter 50, a program memory 60, an instruction register 70, a decoder 80 and an executing unit 90. In a first cycle, the program counter 50 reads data in respective memory addresses of the program memory 60 in sequence, and transmits the data into the instruction register 70. In a second cycle, the instruction register 70 sends an instruction obtained according to the data to the decoder 80, which decodes the instruction. Then the decoded instruction is sent to the executing unit 90 to execute a program in a third cycle.
As mentioned above, a ROM is typically used as the program memory 60, the reasons for which are described as follows. The capacity of the ROM is usually larger than that of a RAM, and the cost of the ROM is lower than the RAM. In addition, most of the built-in programs of the CPU have no need to be amended, so all of the CPUs currently available utilize ROMs as program memories thereof.
However, if the program codes in the ROM have bugs, it is not possible to modify the program codes. Therefore, the CPU having bugs in the built-in programs has to be abandoned, resulting in increase of cost and trouble of operation. Although other types of memories, such as EPROM, EEPROM, FLASH ROM and SRAM, can be used as the program memory 60, however, as there are usually only a few codes which need to be amended, it is not necessary to use such expensive memories.
Accordingly, a method to solve the above problems is needed.